package model

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

// 商品属性表
type GoodsProperty struct {
	gorm.Model
	Name    string `gorm:"column:name;type:varchar(255)" json:"name"`
	GoodsId int64  `gorm:"column:goods_id;type:int(11)" json:"goods_id"`
}

func (g *GoodsProperty) GetGoodsPropertyByGoodsId(goodsId int64) (infos []*GoodsProperty, err error) {
	err = mysql.WithMysql(func(db *gorm.DB) error {
		return db.Model(g).Where("goods_id=?", goodsId).Find(&infos).Error
	})
	return
}
